package com.hmall.common.dto;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
public class ItemDoc {
    @TableId(type = IdType.AUTO)
    private Long id; //商品id
    private String name; //SKU名称
    private Long price; //价格
    private Integer stock;//库存数量
    private String image; //商品图片
    private String category; //类目名称
    private String brand; //品牌名称
    private String spec;//规格
    private Integer sold;//销量
    private Integer comment_count; //评论数
    @TableId("isAD")
    private Boolean isAD; //是否推送广告
    private Integer status;
    private Date create_time;
    private Date update_time;
    //增加自动不全字段
    private List<String> suggestion;//用于自动补全字段

public ItemDoc(Item item){
    this.id = item.getId();
    this.name = item.getName();
    this.price = item.getPrice();
    this.image = item.getImage();
    this.category = item.getCategory();
    this.brand = item.getBrand();
    this.comment_count = item.getCommentCount();
    this.isAD = item.getIsAD();

    //给自动补全字段赋值
    //填充suggestion字段： brand city business
    suggestion = new ArrayList<>();
    suggestion.add(item.getBrand());
    suggestion.add(item.getCategory());
    suggestion.add(item.getName());

}


}
